package com.lzy.cloud.payment.pay.alipay;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.io.InputStream;
import java.util.Properties;

public class AlipayConfig {
    static Log LOG = LogFactory.getLog(AlipayConfig.class);
    // 商户appid
    public static String APPID;
    // 私钥 pkcs8格式的    RSA公私钥生成：https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.nBDxfy&treeId=58&articleId=103242&docType=1
    public static String RSA_PRIVATE_KEY;
    // 请求网关地址
    public static String URL;
    // 编码
    public static String CHARSET;
    // 返回格式
    public static String FORMAT;
    // 支付宝公钥   查看地址：https://b.alipay.com/order/pidAndKey.htm
    public static String ALIPAY_PUBLIC_KEY;
    // 日志记录目录
    public static String log_path;
    // RSA2
    public static String SIGNTYPE;
    //异步回调地址
    public static String NOTIFY_URL;
    //同步回调地址
    public static String RETURN_URL;
    //手续费
    public static String FEE;

    //初始化
    static {
        try {
            Properties pro = new Properties();
            InputStream in = AlipayConfig.class.getClassLoader().getResourceAsStream("props/alipay.properties");
            pro.load(in);
            APPID = pro.getProperty("APPID");
            RSA_PRIVATE_KEY = pro.getProperty("RSA_PRIVATE_KEY");
            URL = pro.getProperty("URL");
            CHARSET = pro.getProperty("CHARSET");
            FORMAT = pro.getProperty("FORMAT");
            ALIPAY_PUBLIC_KEY = pro.getProperty("ALIPAY_PUBLIC_KEY");
            log_path = pro.getProperty("log_path");
            SIGNTYPE = pro.getProperty("SIGNTYPE");
            NOTIFY_URL = pro.getProperty("NOTIFY_URL");
            RETURN_URL = pro.getProperty("RETURN_URL");
            FEE = pro.getProperty("FEE");
        } catch (Exception e) {
            LOG.error("支付宝支付参数初始化出错......" + e.getMessage());
            e.printStackTrace();
        }
    }
}
